package study.java.jdk.jdk8._7_optional;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.Optional;

@Slf4j
public class Optional_Test {


    /**
     * ==============================
     * （★）
     * ==============================
     */
    @Test
    public void of_test() {
        //
        Car car = null;
        //
        String logo = Optional.of(car)
                .map(Car::getLogo)
                .orElse("");
        log.info("{}", logo);
    }

    @Test
    public void ofNullable_test() {
        //
        Car car = null;
        //
        String logo = Optional.ofNullable(car)
                .map(Car::getLogo)
                .orElse("123213");
        log.info("{}", logo);
    }

    /**
     * ==============================
     * （★）
     * ==============================
     */
    @Test
    public void isPresent_test() {
        Optional<Car> optional = Optional.empty();
        log.info("{}", optional.isPresent());
    }

    @Test
    public void ifPresent_test() {
        Optional<Car> optional = Optional.empty();
    }

    /**
     * ==============================
     * （★）
     * ==============================
     */
    @Test
    public void empty_test() {
        Optional<Car> car = Optional.empty();
    }
}
